<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
    <style>
        .v-enter-from,
        .v-leave-to {
            opacity: 0;
        }

        .v-enter-active,
        .v-leave-active {
            transition: opacity 2s ease-in;
        }
    </style>
</head>

<body>
    <div id="app"></div>
</body>
<script>
    let demo = {
        template: `<div>demo</div>`
    }
    let ipt = {
        template: `<div>ipt</div>`
    }
    let vm = {
        components: { demo, ipt },
        data () {
            return {
                show: true
            }
        },
        template: `
                    <div>
                        <transition mode="out-in">
                            <demo v-if="show" />
                            <ipt v-else/>
                        </transition>
                        <button @click="show=!show">切换</button>
                    </div>
                    `
    }
    Vue.createApp(vm).mount('#app')
</script>

</html>